//package com.bins.langchain.ai.rag.test;
//
//import dev.langchain4j.model.chat.ChatLanguageModel;
//import dev.langchain4j.model.openai.OpenAiChatModel;
//import dev.langchain4j.service.AiServices;
//import dev.langchain4j.service.UserMessage;
//
//import java.time.LocalDate;
//
//import static java.time.Duration.ofSeconds;
//
//public class OpenAiDemo {
//
//    static ChatLanguageModel model = OpenAiChatModel.builder()
//            .baseUrl(ApiKeys.BASE_URL)
//            .apiKey(ApiKeys.OPENAI_API_KEY)
//            .logRequests(true)
//            .logResponses(true)
//            .timeout(ofSeconds(6000))
//            .build();
//
//    static class Person {
//
//        private String firstName;
//        private String lastName;
//        private LocalDate birthDate;
//
//        @Override
//        public String toString() {
//            return "Person {" +
//                    " firstName = \"" + firstName + "\"" +
//                    ", lastName = \"" + lastName + "\"" +
//                    ", birthDate = " + birthDate +
//                    " }";
//        }
//    }
//
//    interface PersonExtractor {
//
//        @UserMessage("Extract information about a person from {{it}}")
//        Person extractPersonFrom(String text);
//    }
//
//    public static void main(String[] args) {
//
//        PersonExtractor extractor = AiServices.create(PersonExtractor.class, model);
//
//        String text = "In 1968, amidst the fading echoes of Independence Day, "
//                + "a child named John arrived under the calm evening sky. "
//                + "This newborn, bearing the surname Doe, marked the start of a new journey.";
//
//        Person person = extractor.extractPersonFrom(text);
//
//        System.out.println(person); // Person { firstName = "John", lastName = "Doe", birthDate = 1968-07-04 }
//    }
//}